package designPattern.obsever.baseObserver
{
	public class ConcreteSubject implements ISubject
	{
		private var observer:Array;
		private var attr_a:String;
		private var attr_b:int;
		
		public function ConcreteSubject()
		{
			observer = [];
		}
		
		public function subscribeObserver(o:IObserver):void
		{
			observer.push(o);
		}
		
		public function unsubsubscribeObserver(o:IObserver):void
		{
			for(var i:int = 0; i < observer.length; i++)
			{
				if(observer[i] == o)
				{
					observer.splice(i, 1);
					break;
				}
			}
		}
		
		public function notifyObservers():void
		{
			for(var i:int = 0; i < observer.length; i++)
			{
				(observer[i] as IObserver).update(attr_a, attr_b);
			}
		}
		
		public function setAttr(attr_a:String, attr_b:int):void
		{
			this.attr_a = attr_a;
			this.attr_b = attr_b;
			notifyObservers();
		}
	}
}